using Microsoft.AspNetCore.Mvc;
using JTZY.Model.Agent.Dto;
using JTZY.Model.Agent;
using JTZY.Service.Agent.IAgentService;
using JTZY.Admin.WebApi.Filters;

//创建时间：2025-02-04
namespace JTZY.Admin.WebApi.Controllers.Agent
{
    /// <summary>
    /// 代理佣金明细
    /// </summary>
    [Verify]
    [Route("agent/Corecmsagentorderdetails")]
    public class CorecmsagentorderdetailsController : BaseController
    {
        /// <summary>
        /// 代理佣金明细接口
        /// </summary>
        private readonly ICorecmsagentorderdetailsService _CorecmsagentorderdetailsService;

        public CorecmsagentorderdetailsController(ICorecmsagentorderdetailsService CorecmsagentorderdetailsService)
        {
            _CorecmsagentorderdetailsService = CorecmsagentorderdetailsService;
        }

        /// <summary>
        /// 查询代理佣金明细列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "corecmsagentorderdetails:list")]
        public IActionResult QueryCorecmsagentorderdetails([FromQuery] CorecmsagentorderdetailsQueryDto parm)
        {
            var response = _CorecmsagentorderdetailsService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询代理佣金明细详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "corecmsagentorderdetails:query")]
        public IActionResult GetCorecmsagentorderdetails(int Id)
        {
            var response = _CorecmsagentorderdetailsService.GetInfo(Id);
            
            var info = response.Adapt<CorecmsagentorderdetailsDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加代理佣金明细
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "corecmsagentorderdetails:add")]
        [Log(Title = "代理佣金明细", BusinessType = BusinessType.INSERT)]
        public IActionResult AddCorecmsagentorderdetails([FromBody] CorecmsagentorderdetailsDto parm)
        {
            var modal = parm.Adapt<Corecmsagentorderdetails>().ToCreate(HttpContext);

            var response = _CorecmsagentorderdetailsService.AddCorecmsagentorderdetails(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新代理佣金明细
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "corecmsagentorderdetails:edit")]
        [Log(Title = "代理佣金明细", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateCorecmsagentorderdetails([FromBody] CorecmsagentorderdetailsDto parm)
        {
            var modal = parm.Adapt<Corecmsagentorderdetails>().ToUpdate(HttpContext);
            var response = _CorecmsagentorderdetailsService.UpdateCorecmsagentorderdetails(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除代理佣金明细
        /// </summary>
        /// <returns></returns>
        [HttpPost("delete/{ids}")]
        [ActionPermissionFilter(Permission = "corecmsagentorderdetails:delete")]
        [Log(Title = "代理佣金明细", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteCorecmsagentorderdetails([FromRoute]string ids)
        {
            var idArr = Tools.SplitAndConvert<int>(ids);

            return ToResponse(_CorecmsagentorderdetailsService.Delete(idArr));
        }

    }
}